# _*_ encoding:utf-8 _*_
from django.contrib.auth.models import Permission, ContentType

from rest_framework.response import Response
from rest_framework.permissions import IsAdminUser
from rest_framework.viewsets import ModelViewSet

from meiduo_admin.serializers.perm_serializers import PermModelSerializer, PermContentTypeSerializer
from meiduo_admin.paginations import MyPage


class PermViewSet(ModelViewSet):
    permission_classes = [IsAdminUser]

    queryset = Permission.objects.all()
    serializer_class = PermModelSerializer
    pagination_class = MyPage

    def content_type(self, request):
        queryset = ContentType.objects.all()
        serializer = PermContentTypeSerializer(queryset, many=True)

        return Response(serializer.data)










